home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / HighlightArea.java < prev    next >
Text File  |  1998-09-15  |  3KB  |  92 lines

  1. /*
  2.  * @(#)HighlightArea.java    1.7 98/03/18
  3.  *
  4.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
  7.  * modify and redistribute this software in source and binary code form,
  8.  * provided that i) this copyright notice and license appear on all copies of
  9.  * the software; and ii) Licensee does not utilize the software in a manner
  10.  * which is disparaging to Sun.
  11.  *
  12.  * This software is provided "AS IS," without a warranty of any kind. ALL
  13.  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
  14.  * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  15.  * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
  16.  * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
  17.  * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
  18.  * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
  19.  * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
  20.  * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
  21.  * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
  22.  * POSSIBILITY OF SUCH DAMAGES.
  23.  *
  24.  * This software is not designed or intended for use in on-line control of
  25.  * aircraft, air traffic, aircraft navigation or aircraft communications; or in
  26.  * the design, construction, operation or maintenance of any nuclear
  27.  * facility. Licensee represents and warrants that it will not use or
  28.  * redistribute the Software for such purposes.
  29.  */
  30.  
  31. import java.awt.Graphics;
  32. import java.net.URL;
  33. import java.net.MalformedURLException;
  34.  
  35. /**
  36.  * An area highlighting ImageArea class.
  37.  * This class extends the basic ImageArea Class to highlight an area of
  38.  * the base image when the mouse enters the area.
  39.  *
  40.  * @author     Jim Graham
  41.  * @version     1.7, 03/18/98
  42.  */
  43. class HighlightArea extends ImageMapArea {
  44.     int hlmode;
  45.     int hlpercent;
  46.  
  47.     /**
  48.      * The argument string is the highlight mode to be used.
  49.      */
  50.     public void handleArg(String arg) {
  51.     if (arg == null) {
  52.         hlmode = parent.hlmode;
  53.         hlpercent = parent.hlpercent;
  54.     } else {
  55.         if (arg.startsWith("darker")) {
  56.         hlmode = parent.DARKER;
  57.         arg = arg.substring("darker".length());
  58.         } else {
  59.         hlmode = parent.BRIGHTER;
  60.         if (arg.startsWith("brighter")) {
  61.             arg = arg.substring("brighter".length());
  62.         }
  63.         }
  64.         hlpercent = Integer.parseInt(arg);
  65.     }
  66.     }
  67.  
  68.     public void makeImages() {
  69.     setHighlight(parent.getHighlight(X, Y, W, H, hlmode, hlpercent));
  70.     }
  71.  
  72.     public void highlight(Graphics g) {
  73.     if (entered) {
  74.         g.drawImage(hlImage, X, Y, this);
  75.     }
  76.     }
  77.  
  78.     /**
  79.      * The area is repainted when the mouse enters.
  80.      */
  81.     public void enter() {
  82.     repaint();
  83.     }
  84.  
  85.     /**
  86.      * The area is repainted when the mouse leaves.
  87.      */
  88.     public void exit() {
  89.     repaint();
  90.     }
  91. }
  92.